using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ODM2KMZ
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public string strPath
        {
            get
            {
                string str;

                str = !base.Request.Url.AbsoluteUri.Contains("?") ? base.Request.Url.AbsoluteUri : base.Request.Url.AbsoluteUri.Remove(base.Request.Url.AbsoluteUri.IndexOf("?"));
                return string.Concat(str.Replace(base.Request.Url.AbsolutePath, ""), base.Request.ApplicationPath);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "ODM2KMZ Gateway";

        }

        protected void btnGo_Click(object sender, EventArgs e)
        {
            if (Page.IsPostBack) GetKMZ();
        }

        private void GetKMZ()
        {
            Response.Redirect(String.Format("{0}ODM2KMZ.aspx?URL={1}&Grouping={2}&Show={3}", strPath, this.txtWaterOneFlow.Text, this.RadioButtonList1.SelectedValue, this.RadioButtonList2.SelectedValue));
        }

        protected void btnGoogleMaps_Click(object sender, EventArgs e)
        {
            if (Page.IsPostBack) gotoGoogleMaps();
        }

        private void gotoGoogleMaps()
        {
            String URL = String.Format("{0}ODM2KMZ.aspx?URL={1}&Grouping={2}&Show={3}", strPath, this.txtWaterOneFlow.Text, this.RadioButtonList1.SelectedValue, this.RadioButtonList2.SelectedValue);
            Response.Redirect(string.Format("http://maps.google.com/maps?f=q&q={0}",URL));
        }
        public void Page_Error(object sender, EventArgs e)
        {
            Exception objErr = Server.GetLastError().GetBaseException();

            Response.Redirect("ErrorHandler.aspx?Errormessage=" + Server.UrlEncode(objErr.Message));
            Server.ClearError();
        }

    

    }
}
